#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

struct node {
	ll r, R, h;
	ld h1, h2;
	ld k;
	ll idx;
} a[1000100], st;

ll n, t, l, r, o, c;
ld num1, num2, pos;
ld p;
ll ok;

inline void check(node xx, ll yy) {
	if (xx.R <= yy) {
		ok = 0;
		pos = xx.h2;
	} else {
		if (yy <= xx.r) {
			ok = 2;
			pos = xx.h1;
		} else {
			p = yy - xx.r;
			p /= xx.k;
			if (p + xx.h2 - xx.h <= xx.h1) {
				ok = 2;
				pos = xx.h1;
			} else {
				ok = 1;
				pos = p + xx.h2 - xx.h;
			}
		}
	}
	return;
}

int main() {
	freopen("wan.in", "r", stdin);
	freopen("wan.out", "w", stdout);
	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld%lld%lld", &st.h, &st.r, &st.R);
		st.k = st.R - st.r;
		st.k /= st.h;
		st.idx = i;
		if (!t) {
			st.h1 = 0;
			st.h2 = st.h;
			a[++t] = st;
		} else {
			l = 1;
			r = t;
			num1 = a[1].h2;
			num2 = a[1].h2;
			while (l <= r) {
				ll mid = (l + r) >> 1;
				check(a[mid], st.R);
				if (ok == 2) {
					num1 = pos;
					l = mid + 1;
				} else {
					if (ok == 1) {
						num1 = pos;
						break;
					} else {
						r = mid - 1;
					}
				}
			}
			l = 1;
			r = t;
			while (l <= r) {
				ll mid = (l + r) >> 1;
				check(a[mid], st.r);
				if (ok == 2) {
					l = mid + 1;
					num2 = pos;
				} else {
					if (ok == 1) {
						num2 = pos;
						break;
					} else {
						r = mid - 1;
					}
				}
			}
			num2 = max(num2, num1 - st.h);
			l = 1;
			r = t;
			o = -1;
			while (l <= r) {
				ll mid = (l + r) >> 1;
				if (a[mid].R >= st.R) {
					l = mid + 1;
				} else {
					o = mid;
					r = mid - 1;
				}
			}
			if (o != -1) {
				for (ll j = o; j <= t; j++) {
					if (st.R > a[j].R && st.r < a[j].R && a[j].k < st.k) {
						p = (a[j].R - st.r);
						p /= st.k;
						p = a[j].h2 - p;
						num2 = max(num2, p);
					} else {
						if (st.r >= a[j].R) {
							break;
						}
					}
				}
			}
			st.h1 = num2;
			st.h2 = num2 + st.h;
			while (t && a[t].h2 <= st.h2) {
				t--;
			}
			a[t].h1 = max(a[t].h1, st.h2);
			a[++t] = st;
		}
	}
	printf("%.10Lf\n", a[1].h2);
	return 0;
}
